package com.javacore.day13.thread.example5;

public class BankAccount {
	public BankAccount(String name, float balance) {
		this.name = name;
		this.balance = balance;
	}

	private String name;
	private float balance;

	public synchronized void deposit(float amount) {
		balance += amount;
		System.out.println("Deposit: " + amount);
	}

	public synchronized void withdraw(float amount) {
		balance -= amount;
		System.out.println("Withdraw: " + amount);
	}

	public synchronized void transfer(float amount, BankAccount target) {
		withdraw(amount);
		target.deposit(amount);
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

}
